//
// Created by ultcrt on 2021/5/19.
//

#ifndef DATA_PROCESSOR_REDIS_IO_H
#define DATA_PROCESSOR_REDIS_IO_H

#include "sw/redis++/redis++.h"
#include "nlohmann/json.hpp"
#include <future>

class RedisIO {
public:
    RedisIO(char* redis_url);

    nlohmann::json fetch(const std::vector<std::string>& keys);

    void push(const std::string& key, const nlohmann::json& val, int max_len);

private:
    sw::redis::Redis redis_server;

    void fetch_thread(const std::string& key, std::promise<nlohmann::json> json_promise);
};


#endif //DATA_PROCESSOR_REDIS_IO_H
